﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TitleDetailsPage.xaml.cs" company="saramgsilva">
//   Copyright (c) 2012 saramgsilva. All rights reserved.
// </copyright>
// <summary>
//   An empty page that can be used on its own or navigated to within a Frame.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Netflix.ClientApp.View
{
    using Netflix.PortableClassLibrary.Model;
    using Netflix.PortableClassLibrary.ViewModel;

    using Windows.UI.Xaml.Navigation;

    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class TitleDetailsPage
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TitleDetailsPage" /> class.
        /// </summary>
        public TitleDetailsPage()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh)
            {
                var titleDetailsViewModel = DataContext as TitleDetailsViewModel;
                if (titleDetailsViewModel != null)
                {
                    titleDetailsViewModel.LoadData(e.Parameter as MyTitle);
                }
            }
        }
    }
}